// Copyright (C) 2009 Jesse Jones
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

using System;
using System.Collections.Generic;

// Methods that should be labeled with PureAttribute. (These should be methods
// which have no visible side effects and therefore can be used with Contract
// methods). TODO: should be part of the xml file.
internal static class PureMethods
{
	public static bool IsPure(string name)
	{
		return m_methods.Contains(name);
	}
	
	private static HashSet<string> m_methods = new HashSet<string>
	{
		"absoluteString",
		"absoluteURL",
		"action",
		"alignment",
		"allKeys",
		"allKeysForObject",
		"allObjects",
		"allValues",
		"alternateTitle",
		"ancestorSharedWithView",
		"anyObject",
		"baseURL",
		"boolValue",
		"bounds",
		"bytes",
		"canBeConvertedToEncoding",
		"capitalizedString",
		"caseInsensitiveCompare",
		"changeInLength",
		"charValue",
		"characterAtIndex",
		"characterIsMember",
		"commonPrefixWithString_options",
		"compare",
		"compare_options",
		"compare_options_range",
		"compare_options_range_locale",
		"componentsSeparatedByCharactersInSet",
		"componentsSeparatedByString",
		"containsIndex",
		"containsIndexes",
		"containsIndexesInRange",
		"containsObject",
		"convertPointFromBase",
		"convertPointToBase",
		"convertPoint_fromView",
		"convertPoint_toView",
		"convertRectFromBase",
		"convertRectToBase",
		"convertRect_fromView",
		"convertRect_toView",
		"convertSizeFromBase",
		"convertSizeToBase",
		"convertSize_fromView",
		"convertSize_toView",
		"copyWithZone",
		"count",
		"countOfIndexesInRange",
		"currentEvent",
		"descriptionInStringsFileFormat",
		"descriptionWithLocale",
		"descriptionWithLocale_indent",
		"displayName",
		"dockTile",
		"doubleValue",
		"earlierDate",
		"editedMask",
		"editedRange",
		"fileModificationDate",
		"fileType",
		"fileURL",
		"firstIndex",
		"firstObjectCommonWithArray",
		"floatValue",
		"fragment",
		"frame",
		"getBytes_maxLength_usedLength_encoding_options_range_remainingRange",
		"getCString_maxLength_encoding",
		"getIndexes_maxCount_inIndexRange",
		"hasMemberInPlane",
		"hasPrefix",
		"hasSuffix",
		"hasUndoManager",
		"host",
		"identifier",
		"image",
		"imagePosition",
		"indexGreaterThanIndex",
		"indexGreaterThanOrEqualToIndex",
		"indexLessThanIndex",
		"indexLessThanOrEqualToIndex",
		"indexOfObject",
		"indexOfObjectIdenticalTo",
		"indexOfObjectIdenticalTo_inRange",
		"indexOfObject_inRange",
		"intValue",
		"integerValue",
		"intersectsIndexesInRange",
		"intersectsSet",
		"invertedSet",
		"isActive",
		"isCancelled",
		"isDescendantOf",
		"isDocumentEdited",
		"isEditable",
		"isEnabled",
		"isEqualToArray",
		"isEqualToAttributedString",
		"isEqualToData",
		"isEqualToDate",
		"isEqualToDictionary",
		"isEqualToIndexSet",
		"isEqualToNumber",
		"isEqualToSet",
		"isEqualToString",
		"isEqualToValue",
		"isFieldEditor",
		"isFileURL",
		"isFinished",
		"isFlipped",
		"isHidden",
		"isHiddenOrHasHiddenAncestor",
		"isHorizontallyResizable",
		"isKeyWindow",
		"isMainThread_i",
		"isMainWindow",
		"isOpaque",
		"isRichText",
		"isRunning",
		"isSelectable",
		"isSubsetOfSet",
		"isSupersetOfSet",
		"isVerticallyResizable",
		"isVisible",
		"keysSortedByValueUsingSelector",
		"keyWindow",
		"lastIndex",
		"lastObject",
		"laterDate",
		"layoutManager",
		"layoutManagers",
		"length",
		"lengthOfBytesUsingEncoding",
		"lineRangeForRange",
		"localizedCaseInsensitiveCompare",
		"localizedCompare",
		"longCharacterIsMember",
		"longLongValue",
		"longValue",
		"lowercaseString",
		"mainMenu",
		"mainWindow",
		"maximumLengthOfBytesUsingEncoding",
		"maxSize",
		"minSize",
		"mutableCopyWithZone",
		"name",
		"needsDisplay",
		"nextResponder",
		"null_",
		"objectAtIndex",
		"objectForKey",
		"objectsForKeys_notFoundMarker",
		"objectsAtIndexes",
		"parameterString",
		"password",
		"path",
		"pointValue",
		"port",
		"propertyForKey",
		"rangeOfCharacterFromSet",
		"rangeOfCharacterFromSet_options",
		"rangeOfCharacterFromSet_options_range",
		"rangeOfComposedCharacterSequenceAtIndex",
		"rangeOfComposedCharacterSequencesForRange",
		"rangeOfString",
		"rangeOfString_options",
		"rangeOfString_options_range",
		"rangeOfString_options_range_locale",
		"rangeValue",
		"rectValue",
		"relativePath",
		"relativeString",
		"resourceSpecifier",
		"scheme",
		"selectedCell",
		"selectedRange",
		"selectedTag",
		"shortValue",
		"sizeValue",
		"state",
		"streamStatus",
		"stringByAppendingString",
		"stringByPaddingToLength_withString_startingAtIndex",
		"stringByFoldingWithOptions_locale",
		"stringByReplacingOccurrencesOfString_withString_options_range",
		"stringByReplacingOccurrencesOfString_withString",
		"stringByReplacingCharactersInRange_withString",
		"stringByTrimmingCharactersInSet",
		"stringValue",
		"string_",
		"subarrayWithRange",
		"subdataWithRange",
		"substringFromIndex",
		"substringToIndex",
		"substringWithRange",
		"superview",
		"tag",
		"target",
		"textContainer",
		"textContainerOrigin",
		"textStorage",
		"timeIntervalSince1970",
		"timeIntervalSinceDate",
		"timeIntervalSinceNow",
		"title",
		"unsignedCharValue",
		"unsignedIntValue",
		"unsignedIntegerValue",
		"unsignedLongLongValue",
		"unsignedLongValue",
		"unsignedShortValue",
		"uppercaseString",
		"user",
		"UTF8String",
		"windowsMenu",
	};
}

